-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Peephole optimizer & proc decoder fixes #2054
Open
ike709
wants to merge
6
commits into
OpenDreamProject:master
Choose a base branch
from
ike709:optfix
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
boring-cyborg
bot
added
Compiler
Involves the OpenDream compiler
Runtime
Involves the OpenDream server/runtime
labels
Oct 21, 2024
ike709
commented
Oct 21, 2024
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR does a few things:
Fixes peephole optimizations not being applied to opcodes created by peephole optimizations. E.g.:
PushNull -> Assign -> Pop
was being optimized toPushNull -> AssignPop
, but the optimizer offset wasn't rolled back far enough to consider optimizingPushNull -> AssignPop
toNullRef
. It would only be rolled back to the newAssignPop
opcode. This meant that theNullRef
opcode was never used, which is now fixed.Fixes a few opcodes not being implemented in
ProcDecoder
. Because a few opcodes were specific to optimizations that were never applied, they never triggered any errors in the disassembler.DreamProcOpcode.NullRef
andDreamProcOpcode.PushNOfStringFloats
can now be decoded.Fixes
PushNOfStringFloats
only being applied to pairs ofStringFloat
s. Because of how the peephole optimizer works, it would (now that it actually runs) try to run thePushNOfStringFloats
optimization before everyPushString
andPushFloat
in the sequence had been converted toStringFloat
s. ThePushNOfStringFloat
s optimization has been folded into theStringFloat
optimization, and it'll just use the relevant opcode depending on how many pairs ofPushString
andPushFloat
opcodes there are. This has the added benefit of reducing the amount of optimizations that need to be applied.We really need to implement a system for unit testing the peephole optimizer on input bytecode, but that is out of scope for this PR.
I made sure that TG doesn't explode, the
NullRef
opcode is now used, and that thePushNOfStringFormat
optimization actually works correctly & disassembles with sane formatting: